package top.kaoshanji.p3ch20c;

import java.util.Vector;

/**
 * 代码清单-p3ch20c-238页b：具体容器
 * @author kaoshanji
 * ^_^
 * create time 2025/3/24 18:44
 */
public class ConcreteAggregate implements Aggregate {

    // 容器对象的容器
    private Vector vector = new Vector();

    // 增加一个元素
    @Override
    public void add(Object object) {
        this.vector.add(object);
    }

    // 删除一个元素
    @Override
    public void remove(Object object) {
        this.remove(object);
    }

    // 返回迭代器对象
    @Override
    public Iterator iterator() {
        return new ConcreteIterator(this.vector);
    }
}
